import axios from 'axios'
import Cookies from 'js-cookie'

let util = {

}

util.Axios = axios.create({
  baseURL: 'https://account.wei3h.com',
  timeout: 30000
})

util.Axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  if (Cookies.get('ptoken')) {
    config['headers']['Authorization'] = 'Bearer ' + Cookies.get('ptoken')
  }
  return config
}, function (error) {
  // Do something with request error
  return Promise.reject(error)
})

export default util
